using System;
using System.Collections.Generic;
using System.Text;
using CIM.Model;
using MWang.Data.ORM;
using MWang.Data;
using MWang.Factory;

namespace CIM.BLL.ArUserSearch
{
   public abstract class BaseUserSearch:logiclayer<UserContactInfo>
   {
       private string _keyword;
       private int _pageIndex;
       private int _pageSize;
       private int _totalRecord;
       private int? _recordCount;
       public BaseUserSearch(string connstr):base(connstr,false)
       {
           if (pager.Para == null)
           {
               pager.Para = new SqlDataPagerPara();
           }
       }

       protected abstract void ConfigPara();
       public SqlDataPager GetPager()
       {
           pager = PagerFactory.CreatePager();
           pager.Para.FieldList = "aid,cname,workplace,livein,oftel,htel,mphone,othercon";
           pager.Para.FieldOutput = "aid,cname,workplace,livein,oftel,htel,mphone,othercon";
           pager.Para.IsDoCount = false;
           pager.Para.OrderField = "aid";
           pager.Para.PageIndex = PageIndex;
           pager.Para.PageSize = PageSize;
           pager.Para.TableName = tableInfo.TableName;
           pager.Para.PageSize = 30;
           pager.Para.PageIndex = 1;
           ConfigPara();
           return pager;
       }
       public List<UserContactInfo> Search()
       {
           pager.Para.FieldList = "aid,cname,workplace,livein,oftel,htel,mphone,othercon";
           pager.Para.FieldOutput = "aid,cname,workplace,livein,oftel,htel,mphone,othercon";
           pager.Para.IsDoCount = false;
           pager.Para.OrderField = "aid";
           pager.Para.PageIndex = PageIndex;
           pager.Para.PageSize = PageSize;
           pager.Para.TableName = tableInfo.TableName;
           ConfigPara();
           return GetPageRecord(pager.Para);
       }

       public int? RecordCount
       {
           get
           {
               if (_recordCount == null)
               {
                   pager.Para.FieldList = "aid,cname,workplace,livein,oftel,htel,mphone,othercon";
                   pager.Para.FieldOutput = "aid,cname,workplace,livein,oftel,htel,mphone,othercon";
                   pager.Para.IsDoCount = false;
                   pager.Para.OrderField = "aid";
                   pager.Para.PageIndex = PageIndex;
                   pager.Para.PageSize = PageSize;
                   pager.Para.TableName = tableInfo.TableName;
                   ConfigPara();
                   pager.Para.IsDoCount = true;
                   pager.GetPage();
                   _recordCount = pager.RecordCount;
               }
               return _recordCount;
           }
           set { _recordCount = value; }
       }

       public string Keyword
       {
           get { return _keyword; }
           set { _keyword = value; }
       }

       public int PageIndex
       {
           get { return _pageIndex; }
           set { _pageIndex = value; }
       }

       public int PageSize
       {
           get { return _pageSize; }
           set { _pageSize = value; }
       }

       public int TotalRecord
       {
           get { return _totalRecord; }
           set { _totalRecord = value; }
       }
   }
}
